import {
  COMMON_STATUS_LABELS,
  COMMON_STATUS_COLORS,
  MENU_TYPE_LABELS,
  MENU_TYPE_COLORS
} from '@nbase/shared';
import type { CommonStatus, MenuType } from '@nbase/shared';

/**
 * 格式化状态标签
 */
export const formatStatusLabel = (status: CommonStatus): string => {
  return COMMON_STATUS_LABELS[status] || '未知';
};

/**
 * 获取状态颜色
 */
export const getStatusColor = (status: CommonStatus): string => {
  return COMMON_STATUS_COLORS[status] || 'default';
};

/**
 * 格式化菜单类型标签
 */
export const formatMenuTypeLabel = (type: MenuType): string => {
  return MENU_TYPE_LABELS[type] || '未知';
};

/**
 * 格式化菜单类型标签
 */
export const getMenuTypeColor = (type: MenuType): string => {
  return MENU_TYPE_COLORS[type] || 'default';
};

/**
 * 格式化日期时间
 */
export const formatDateTime = (dateTime: string | Date | null | undefined): string => {
  if (!dateTime) return '-';
  const date = typeof dateTime === 'string' ? new Date(dateTime) : dateTime;
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
  });
};

/**
 * 格式化日期
 */
export const formatDate = (date: string | Date): string => {
  if (!date) return '-';
  const d = typeof date === 'string' ? new Date(date) : date;
  return d.toLocaleDateString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
  });
};

/**
 * 格式化时间
 */
export const formatTime = (time: string | Date): string => {
  if (!time) return '-';
  const t = typeof time === 'string' ? new Date(time) : time;
  return t.toLocaleTimeString('zh-CN', {
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
  });
};

